﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Kanban.Business;
using Kanban.Entity;
using System.Collections.Generic;

namespace Kanban.Test
{
    [TestClass]
    public class Testes_Tarefa
    {
        [TestMethod]
        public void Deve_Adicionar_Nova_Tarefa()
        {
            var business = new TarefaBusiness();

            var tarefa = new Tarefa();
            tarefa.Descricao = "TAREFA TESTE";
            tarefa.CriadaPor = new Usuario();
            tarefa.CriadaPor.Id = 1;
            tarefa.Quadro = new Quadro();
            tarefa.Quadro.Id = 1;

            business.Adicionar(tarefa);

            Assert.IsTrue(tarefa.Id > 0);
        }

        [TestMethod]
        public void Deve_Obter_Tarefa_Por_Id()
        {
            var business = new TarefaBusiness();

            Tarefa tarefa = business.ObterPorId(2);

            Assert.IsNotNull(tarefa);
            Assert.IsTrue(tarefa.Id > 0);
        }

        [TestMethod]
        public void Deve_Listar_Tarefas_De_Um_Quadro()
        {
            var business = new TarefaBusiness();

            List<Tarefa> lista = business.ListarPorIdQuadro(1);

            Assert.IsNotNull(lista);
            Assert.IsTrue(lista.Count > 0);
        }

        [TestMethod]
        public void Deve_Excluir_Tarefa_Por_Id()
        {
            var business = new TarefaBusiness();

            var tarefa = new Tarefa();
            tarefa.Descricao = "Tarefa TESTE";
            tarefa.CriadaPor = new Usuario();
            tarefa.CriadaPor.Id = 1;
            tarefa.Quadro = new Quadro();
            tarefa.Quadro.Id = 1;

            business.Adicionar(tarefa);

            business.Remover(tarefa.Id);

            Tarefa tarefaExcluida = business.ObterPorId(tarefa.Id);

            Assert.IsNull(tarefaExcluida);
        }
    }
}
